﻿using System;
using fastCSharp;

namespace diantou.dataModel
{
    /// <summary>
    /// 企业考试用户上传数据
    /// </summary>
    public class examUserUpload
    {
        /// <summary>
        /// 用户姓名
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 16)]
        public string Name;
        /// <summary>
        /// 手机号
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 16, IsAscii = true)]
        public string MobileString;
        /// <summary>
        /// 电子邮箱
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 256, IsAscii = true)]
        public string Email = string.Empty;
        /// <summary>
        /// 身份证号
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 18, IsAscii = true)]
        public string IdCard = string.Empty;
        /// <summary>
        /// 学校
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 64)]
        public string School = string.Empty;
        /// <summary>
        /// 专业
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 16)]
        public string Special = string.Empty;
        /// <summary>
        /// 生日
        /// </summary>
        public fastCSharp.sql.member.intDate Birthday;
        /// <summary>
        /// 生日
        /// </summary>
        internal string BirthdayString
        {
            set
            {
                DateTime date;
                if (DateTime.TryParse(value, out date))
                {
                    Birthday = date.toInt();
                }
            }
        }
        /// <summary>
        /// 性别类型
        /// </summary>
        public enum sex : byte
        {
            所有,
            暂无,
            男,
            女
        }
        /// <summary>
        /// 性别类型
        /// </summary>
        public sex Sex;
        /// <summary>
        /// 学历要求
        /// </summary>
        public enum education : byte
        {
            不限,
            暂无,
            大专,
            本科,
            硕士,
            博士
        }
        /// <summary>
        /// 学历要求
        /// </summary>
        public education Education;
        /// <summary>
        /// 是否测试用户
        /// </summary>
        [fastCSharp.emit.dataSerialize.member(IsIgnoreCurrent = true)]
        public bool IsTest;
        /// <summary>
        /// 数据检测
        /// </summary>
        /// <returns>手机号</returns>
        public long Check()
        {
            if (Name.length() != 0 && MobileString.Length >= 11 && Email.IndexOf('@') > 0)
            {
                long mobile;
                if (long.TryParse(MobileString, out mobile) && mobile >= 10000000000)
                {
                    if (Education == education.不限) Education = education.暂无;
                    if (Sex == sex.所有) Sex = sex.暂无;
                    return mobile;
                }
            }
            return 0;
        }
        /// <summary>
        /// 数据手机号
        /// </summary>
        /// <returns>手机号</returns>
        public long CheckMobile()
        {
            long mobile;
            return MobileString.Length >= 11 && long.TryParse(MobileString, out mobile) && mobile >= 10000000000 ? mobile : 0;
        }
        /// <summary>
        /// 数据检测
        /// </summary>
        /// <returns>手机号</returns>
        public bool CheckEmail()
        {
            if (Name.length() != 0 && Email.IndexOf('@') > 0)
            {
                if (Education == education.不限) Education = education.暂无;
                if (Sex == sex.所有) Sex = sex.暂无;
                return true;
            }
            return false;
        }
    }
    /// <summary>
    /// 企业考试用户下载数据
    /// </summary>
    public abstract class examUserDownload : examUserUpload
    {
        /// <summary>
        /// 开始考试时间
        /// </summary>
        public DateTime ExamTime = fastCSharp.pub.MinTime;
        /// <summary>
        /// 考试交卷时间
        /// </summary>
        public DateTime SubmitTime = fastCSharp.pub.MinTime;
        /// <summary>
        /// 手机号
        /// </summary>
        [fastCSharp.emit.dataMember(PrimaryKeyIndex = 2)]
        public long Mobile;
        /// <summary>
        /// 单选题正确数量
        /// </summary>
        public int RadioRightCount;
        /// <summary>
        /// 多选题分数
        /// </summary>
        public int MultipleChoicePoint;
        /// <summary>
        /// 编程题分数
        /// </summary>
        public int ProblemPoint;
        /// <summary>
        /// 问答题分数
        /// </summary>
        public int QuestionPoint;
        /// <summary>
        /// 用户状态
        /// </summary>
        public enum status : byte
        {
            所有,
            未判卷,
            未确定,
            已通过,
            已淘汰
        }
        /// <summary>
        /// 用户状态
        /// </summary>
        public status Status = status.未判卷;
        /// <summary>
        /// 是否注册
        /// </summary>
        public bool IsRegister;

        /// <summary>
        /// 考试得分
        /// </summary>
        [fastCSharp.emit.dataMember(IsIgnoreCurrent = true)]
        public int ExamPoint;
    }
    /// <summary>
    /// 企业考试用户
    /// </summary>
    [fastCSharp.emit.jsonSerialize(IsAllMember = true)]
    [fastCSharp.emit.jsonParse(IsAllMember = true)]
    [fastCSharp.emit.dataSerialize(IsReferenceMember = false)]
    [fastCSharp.code.cSharp.webView.clientType(Name = "diantou.examUser")]
    [fastCSharp.code.cSharp.sqlModel(LogTcpCallService = "ExamDataLog", IsLogClientQueue = true)]
    public partial class examUser : examUserDownload
    {
        /// <summary>
        /// 企业考试用户标识
        /// </summary>
        [fastCSharp.code.cSharp.webView.outputAjax]
        public int Id;
        /// <summary>
        /// 企业考试标识
        /// </summary>
        [fastCSharp.emit.dataMember(PrimaryKeyIndex = 1)]
        public int ExamId;
        /// <summary>
        /// 验证码
        /// </summary>
        public uint MobileCode;
        /// <summary>
        /// 头像
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 256, IsAscii = true)]
        [fastCSharp.code.cSharp.webView.outputAjax(BindingName = "Sex")]
        public sqlMember.image Icon = string.Empty;
        /// <summary>
        /// 试卷评审人员标识
        /// </summary>
        public int ReviewUserId;
        /// <summary>
        /// 考试邀请标识
        /// </summary>
        public int InvitationId;
        /// <summary>
        /// 图片数量
        /// </summary>
        public int ImageCount;
        /// <summary>
        /// 是否提交考试
        /// </summary>
        [fastCSharp.emit.dataSerialize.member(IsIgnoreCurrent = true)]
        public bool IsSubmit;
        /// <summary>
        /// 是否存在考试日志
        /// </summary>
        public bool IsLog;
        /// <summary>
        /// 是否机器判题结束
        /// </summary>
        public bool IsJudged;
        /// <summary>
        /// 是否使用过摄像头
        /// </summary>
        public bool IsCamera;
        /// <summary>
        /// 代码相似提交标识
        /// </summary>
        public struct checkJudge
        {
            /// <summary>
            /// 当前用户提交标识
            /// </summary>
            public int JudgeId;
            /// <summary>
            /// 相似代码提交标识
            /// </summary>
            public int SimilarId;
            /// <summary>
            /// 相似度
            /// </summary>
            public int Similarity;
            /// <summary>
            /// 代码相似提交标识
            /// </summary>
            /// <param name="similarJudgeId"></param>
            /// <param name="similarity"></param>
            public void Set(int similarJudgeId, int similarity)
            {
                SimilarId = similarJudgeId;
                Similarity = similarity;
            }
        }
        /// <summary>
        /// 编程题测试标识集合
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 256, IsAscii = true)]
        public fastCSharp.sql.jsonMember<checkJudge[]> JudgeIds;
        /// <summary>
        /// 编程日志问题集合
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 256, IsAscii = true)]
        public fastCSharp.sql.jsonMember<int[]> LogProblemIds;
        /// <summary>
        /// 上传简历
        /// </summary>
        [fastCSharp.emit.dataMember(MaxStringLength = 256, IsAscii = true)]
        public string Resume = string.Empty;

        /// <summary>
        /// 当前考试题目编号
        /// </summary>
        [fastCSharp.emit.dataMember(IsIgnoreCurrent = true, IsSqlStream = true)]
        public int QuestionIndex;
        /// <summary>
        /// 摄像头同步时间
        /// </summary>
        [fastCSharp.emit.dataMember(IsIgnoreCurrent = true, IsSqlStream = true)]
        public DateTime CameraTime;
    }
}
